import request from '@/utils/request';
import { Order } from '../model';

const prefix = '/orders';

export async function list(payload: Order): Promise<Order[]> {
  return request(prefix, {
    params: payload,
  });
}

export async function get(id: number): Promise<Order> {
  return request(`${prefix}/get/${id}`);
}

export async function remove(id: number): Promise<number> {
  return request(`${prefix}/${id}`, {
    method: 'DELETE',
  });
}

export async function update(payload: Order): Promise<number> {
  return request(`${prefix}/${payload.id}`, {
    method: 'PUT',
    data: payload,
  });
}
